<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:o="http://omnifaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:sec="http://www.springframework.org/security/facelets/tags">
<f:view xmlns="http://www.w3.org/1999/xhtml"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets">
	<h:head>
		<f:facet name="first">
			<meta content='text/html; charset=UTF-8' http-equiv="Content-Type" />
			<title>我要吃饭</title>
		</f:facet>
		
		<style>
		
body {
	background-color: #F7F7F7;
	font-size: 12px;
}

.loginPanel {
	width: 500px;
	margin: 0 auto;
	margin-top: 180px;
}

#verifyCode {
	vertical-align: middle;
}
</style>
<script src="http://g.alicdn.com/dingding/dinglogin/0.0.5/ddLogin.js"></script>
	<script>
//	<![CDATA[
// 		 解释一下goto参数，参考以下例子：
// 		alert();
		var url = encodeURIComponent("http://www.summor.cn");
		var _goto = encodeURIComponent("https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=appid&response_type=code&scope=snsapi_login&state=STATE&redirect_uri="+url);
		
		var obj = DDLogin({
		     id:"login_container",//这里需要你在自己的页面定义一个HTML标签并设置id，例如<div id="login_container"></div>或<span id="login_container"></span>
		     goto: _goto, //请参考注释里的方式
		     style: "border:none;background-color:#FFFFFF;",
		     width : "365",
		     height: "400"
		 });
		
		var hanndleMessage = function (event) {
	        var origin = event.origin;
	        console.log("origin", event.origin);
	        if( origin == "https://login.dingtalk.com" ) { //判断是否来自ddLogin扫码事件。
	            var loginTmpCode = event.data; //拿到loginTmpCode后就可以在这里构造跳转链接进行跳转了
	            console.log("loginTmpCode", loginTmpCode);
	        }

		};
	
		if (typeof window.addEventListener != 'undefined') {
		    window.addEventListener('message', hanndleMessage, false);
		} else if (typeof window.attachEvent != 'undefined') {
		    window.attachEvent('onmessage', hanndleMessage);
		}
		//]]>
	</script>
		<link href="#{request.contextPath}/include/css/admin.css"
			type="text/css" rel="stylesheet" />
		<link href="#{request.contextPath}/include/css/login.css"
			type="text/css" rel="stylesheet" />
			
			<link href="#{request.contextPath}/include/images/admin/favicon.png"
			type="image/x-icon" rel="shortcut icon" />
	</h:head>
	<f:event type="preRenderComponent"
		listener="#{loginUtil.setSession('loginType','admin')}"></f:event>
		
	<div style="width: 280px;position: absolute;left: 50%;height: 532px;padding: 35px;color: #EEE;left: 50%;top: 100px;margin-left: -175px;">
		<form name="loginform" action="#{request.contextPath}/login" method="post"
			
			accept-charset="UTF-8">
			<ui:fragment
				rendered="#{ not empty requestScope['SPRING_SECURITY_LAST_EXCEPTION'] and requestScope['SPRING_SECURITY_LAST_EXCEPTION'].message ne 'Authentication method not supported: GET'}">
				<script>
					$(function() {
						growl
								.renderMessage({
									summary : '错误',
									detail : '#{requestScope['SPRING_SECURITY_LAST_EXCEPTION'].message}',
									severity : 'error'
								});
					});
				</script>
				<!--             <li style="color: red;"> -->
				<!--                 #{requestScope['SPRING_SECURITY_LAST_EXCEPTION'].message} -->
				<!--             </li> -->
			</ui:fragment>
			<ui:fragment
				rendered="#{not empty request.getParameter('spring-security-redirect')}">
				<input type="hidden" name="spring-security-redirect"
					value="#{request.getParameter('spring-security-redirect')}"></input>
			</ui:fragment>
			
			<div class="input_outer">
				<span class="u_user"></span>
				<p:inputText styleClass="text" label="用户名" id="j_username" style="box-shadow: inset 0 0px 0px #ffffff;color: rgba(153,217,234,0.8) !important;"
					required="true"></p:inputText>
			</div>
	
			<div class="input_outer">
				<span class="us_uer"></span>
				<p:password styleClass="text" id="j_password"  style="box-shadow: inset 0 0px 0px #ffffff;color: rgba(153,217,234,0.8) !important;"></p:password>
	
			</div>
			<h:outputLabel value="验证码"
				rendered="#{sessionScope.need_validate_code or configHome.getConfigValue('login_fail_max_times') eq '0'}"></h:outputLabel>
			<h:outputLabel
				rendered="#{sessionScope.need_validate_code or configHome.getConfigValue('login_fail_max_times') eq '0'}">
				<p:inputText id="captcha_input" style="width:60px;"></p:inputText>
				<img alt="点击刷新" id="verifyCode"
					src="#{request.contextPath}/verifyCodeServlet"
					onclick="this.src='#{request.contextPath}/verifyCodeServlet?'+new Date().getTime()" />
			</h:outputLabel>
	
			<p:spacer></p:spacer>
			<div class="mb2">
				<p:outputPanel>
					<p:commandLink styleClass="act-but submit" style="color: #FFFFFF;font-size:20px;" value="上！" onclick="loginform.submit();"></p:commandLink>
				</p:outputPanel>
				
			</div>
	<!-- 		<div class="mb2"><a class="act-but submit" href="javascript:;" style="color: #FFFFFF">登录</a></div> -->
			
			<div class="clear"></div>
		</form>
		<h:form id="dingForm">
			<p:commandLink styleClass="act-but submit" style="color: #FFFFFF;font-size:20px;text-decoration:none" value="钉钉登录" actionListener="#{userHome.toALiDingDing('login')}"></p:commandLink>
			<div class="login-logo">
				<img src="#{request.contextPath}/include/images/admin/login-logo.png"
					style="width:135px;height:120px;" />
			</div>
		</h:form>
		</div>
	<div id="login_container"></div>

</f:view>
</html>